import os
# 设置 TensorFlow 的运行日志等级为 2 ---Warning
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf


if __name__ == '__main__':
    devices = tf.config.list_logical_devices()
    print(devices)

    cpu_devices = tf.config.list_physical_devices("CPU")
    if cpu_devices:
        print(cpu_devices)
    else:
        print("No CPU Device")

    gpu_devices = tf.config.list_physical_devices("GPU")
    if gpu_devices:
        print(gpu_devices)
    else:
        print("No GPU Device")